﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>部门选择</title>
    <!-- Bootstrap -->
    <link href="/ViewV5/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet">
    <link href="/ViewV5/JS/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        body {
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none; /*元素不能被选中*/
        }

        .lev1 {
            /*//  margin-left: 10px;*/
        }

        .lev2 {
            padding-left: 40px;
        }

        .list-group .lev2:first-child {
            padding-left: 40px;
            border-top: 1px solid #ddd !important;
        }


        .media-left {
            padding-right: 5px;
        }

        .media-body {
            padding-top: 5px;
        }

        .media-heading {
            margin-top: 8px;
        }

        .list-group-item:hover {
            background-color: #3085DB;
        }


        .isel {
            top: 0;
            right: 0;
            color: darkgoldenrod;
            font-size: 16px;
        }

        .pCard {
            min-width: 110px;
            max-width: 300px;
            text-align: center;
            margin: 8px 3px;
        }

        .pHead {
            margin: 4px;
            border-radius: 3px;
            float: left;
            height: 45px;
            width: 45px;
        }


        .pName {
            padding: 15px 0 0 0;
            position: relative;
            display: inline-block;
            font-weight: normal;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 14px;
        }

        .pCard:hover {
            border-color: #66c9f3;
            box-shadow: 0 0px 10px #66c9f3;
            cursor: pointer;
        }

        .pCardSelect {
            border-color: #66c9f3;
            box-shadow: 0 0px 10px #66c9f3;
            cursor: pointer;
        }

        .pStatus {
            color: #1288c5;
            font-size: 12px;
        }

        .pCard:hover .badge {
            visibility: visible;
        }

        .panel-body .badge {
            position: absolute;
            top: -5px;
            right: -6px;
            background-color: red;
            padding-left: 5px;
            padding-right: 5px;
            visibility: collapse;
        }

        .panel-body .usersel {
            position: absolute;
            top: -5px;
            right: -6px;
            padding-left: 5px;
            padding-right: 5px;
        }

        .ztree * {
            font-size: 15px;
        }
    </style>
</head>
<body ms-controller="BranchSelect">
    <div class="container-fluid " style="margin:10px" id="dvContent">
        <div style="width:150px;position:absolute;">
         
            <div class="tab-content">
                <ul id="tree" class="ztree"></ul>
            </div>
        </div>

    </div>
     
    <script src="/ViewV5/JS/jquery-1.11.2.min.js"></script>
    <script src="/ViewV5/JS/avalon1.47.js"></script> 
    <script src="/ViewV5/JS/SZHLCommon.js?jsver=20160915"></script> 
    <script src="/ViewV5/JS/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
    <script src="/ViewV5/JS/zTree_v3/js/jquery.ztree.excheck-3.5.min.js"></script>
    <script>
        var zTreeObj = null;
        var model = avalon.define({
            $id: "BranchSelect",
            isSignle: ComFunJS.getQueryString("issignle") ? ComFunJS.getQueryString("issignle") : "Y",
            checkval: ComFunJS.getQueryString("checkvalue") ? ComFunJS.getQueryString("checkvalue") : "",
            isqx: ComFunJS.getQueryString("isqx") ? ComFunJS.getQueryString("isqx") : "N",

            selBM: "",//已选择部门
            getBranchTree: function () { //获取组织机构
                var setting = {
                    data: {
                        simpleData: {
                            enable: true,
                            idKey: "id",
                            pIdKey: "pId",
                            rootPId: 0
                        }
                    },

                    view: {
                        showLine: false
                    },
                    callback: {
                        beforeClick: zTreeBeforeClick,
                        onClick: model.zTreeOnClick
                    }, check: {
                        enable: true,
                        chkStyle: (model.isSignle == "Y" ? "radio" : "checkbox"),//"checkbox"
                        chkboxType: { "Y": model.isSignle == "Y" ? "p" : "s", "N": model.isSignle == "Y" ? "p" : "s" },
                        radioType :"all" 
                    }
                };
                $.getJSON("/api/Auth/ExeAction?Action=GETALLBMUSERLISTNEW", { P1: model.checkval, P2: model.isqx }, function (msg) {
                    zTreeObj = $.fn.zTree.init($("#tree"), setting, eval(msg.Result));
                });
            }
        })
        avalon.ready(function () { 
            model.getBranchTree();
        })
        function zTreeBeforeClick(treeId, treeNode, clickFlag) {
            return !treeNode.isParent;//当是父节点 返回false 不让选取
        };
        function getselectedbranch() {
            var nodes = zTreeObj.getCheckedNodes(true);
            var branchid = "";
            var branchname = "";
            nodes.forEach(function (item) {
                branchid = branchid + item.id + ",";
                branchname = branchname + item.name + ",";
            })
            branchid = branchid.substr(0, branchid.length - 1);
            branchname = branchname.substr(0, branchname.length - 1);
            var branchinfo = { 'branchid': branchid, 'branchname': branchname };
            return branchinfo;

        }
    </script>
</body>
</html>